package com.xinyue.game.server.dispatcher;

import com.xinyue.game.server.codec.GameMessageHeader;
import com.xinyue.game.server.codec.message.IGameMessage;
import com.xinyue.game.server.common.GameServerTimeUtil;

import io.netty.channel.ChannelHandlerContext;

public class GameServerContext {

	private ChannelHandlerContext channelHandlerContext;
	private GameMessageHeader header;

	public GameServerContext(ChannelHandlerContext channelHandlerContext, GameMessageHeader header) {
		super();
		this.channelHandlerContext = channelHandlerContext;
		this.header = header;
	}

	public void sendResponse(IGameMessage response) {
		GameMessageHeader responseHeader = response.getHeader();
		responseHeader.setSendTime(GameServerTimeUtil.currentTimeMillis());
		responseHeader.setSeqId(header.getSeqId());
		channelHandlerContext.writeAndFlush(response);
	}

}
